// 判断是不是二叉搜索树

#include <vector>
using namespace std;

struct TreeNode 
{
    int val;
	struct TreeNode *left;
	struct TreeNode *right;
	TreeNode(int x)
        : val(x)
        , left(nullptr)
        , right(nullptr)
    {}
};
class Solution 
{
public:
    void InOrder(TreeNode* root, vector<int>& v)
    {
        if(!root) return;

        InOrder(root->left, v);
        v.push_back(root->val);
        InOrder(root->right, v);
    }
    bool isValidBST(TreeNode* root) 
    {
        // write code here
        vector<int> v;
        InOrder(root, v);
        for(int i = 1; i < v.size(); i++)
        {
            if(v[i - 1] >= v[i]) return false;
        } 
        return true;
    }
};